import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'

@Entity('posts')
export class PostsEntity {
  @PrimaryGeneratedColumn() // 标记为主列，值自动生成
  id: number

  @Column({ length: 50 })
  title: string

  @Column({ length: 20 })
  author: string

  @Column('text')
  content: string

  @Column({ default: '文章封面' })
  cover_url: string

  @Column({
    name: 'create_time',
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
  })
  createTime: Date;
}
